/*
 * Created on 16/Dez/2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package jhub;

import java.io.*;

/**
 * @author botelhodaniel
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class DCBufferedReader extends BufferedReader {
    private char separator;
    
    public DCBufferedReader(InputStreamReader in) {
        super(in);
        this.separator = '|';
    }
    
    public String readLine() throws IOException {
        StringBuffer buffer = new StringBuffer();

        while (!buffer.toString().endsWith(separator+"") || this.ready()) {
            //System.out.println("this.ready()"+this.ready());
            int c = read();
            //System.out.println(c);
            if(c<0)
            	throw new java.net.SocketException("Connection reset");
            else
            	buffer.append((char)c);
        }
        return buffer.toString();
    }
}
